package dao;

import java.sql.CallableStatement;
import java.sql.Connection;

import java.sql.SQLException;

import db.DbController;

public class DbApproveds {

///////////////////////
    public static int insert(String word, String meaning, int dictID) {
    	
    	Connection cnn = null;
        CallableStatement cstat = null;
        
        try {
            cnn = DbController.getConnection();
            cstat = cnn.prepareCall("{call m_approveds_insert(?,?,?)}");
            cstat.setString(1, word);
            cstat.setString(2, "N'" + meaning + "'");
            cstat.setInt(3, dictID);
            
            return cstat.executeUpdate();
        }
        
        catch (SQLException e) {
			// TODO: handle exception
        	return 0;
		}       

    }
    
    public static int update(String word, int dictID, String meaning) {
	
    	Connection cnn = null;
        CallableStatement cstat = null;
        
        try {
            cnn = DbController.getConnection();
            cstat = cnn.prepareCall("{call update_approved_meaning(?,?,?)}");
            cstat.setString(1, word);
            cstat.setInt(2, dictID);
            cstat.setString(3, "N'" + meaning + "'");
            
            return cstat.executeUpdate();
        }
        
        catch (SQLException e) {
			// TODO: handle exception
        	
        	return 0;
		}       
 	
	}
    
    
}




















 